﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Client;
using System.IO;

namespace ImportHub2007Content
{
    class Program
    {
        
        static void DisplayUsage()
        {
            Console.WriteLine("ImportHub2007Content - performs migration of key content from an existing 2007 Productivity Hub site collection to an existing 2010 Productivity Hub site.\r\n");
            Console.WriteLine("Required Parameter:");
            Console.WriteLine("\t-target [hub2010Url] ");
            Console.WriteLine();
            Console.WriteLine("Example:");
            Console.WriteLine("ImportHub2007Content -target http://farm2/sites/productivityHub");
            Console.WriteLine();
            
        }

        static void Main(string[] args)
        {
            // validate params
            Arguments parseArgs = new Arguments(args);
            if (String.IsNullOrEmpty(parseArgs["target"]))
            {
                // one or more required params are null/empty
                Console.WriteLine("Error: A required parameter is missing");
                DisplayUsage();
            }
            else
            {
                string logFileName = "ImportHub_" + System.IO.Path.GetRandomFileName().Replace('.', 'a') + ".log";
                System.IO.StreamWriter _logFile = System.IO.File.CreateText(logFileName);

                Importer m = new Importer(_logFile);
                m.TargetUrl = parseArgs["target"];
                
                m.PerformImport();

            }

        }
    }
}
